Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(depinject/appconfig): remove api module dependency #20931

Merged
merged 13 commits into from
Jul 18, 2024

Conversation

aaronc
Copy link
Member

@aaronc aaronc commented Jul 10, 2024

Description

This PR removes the dependency on the api module in depinject by generating the needed types in depinject/appconfig using gogo proto and doing dynamic conversions using protoreflect as necessary.

The modification of Compose to take simply gogoproto.Message should be non-breaking for users (unless someone is using it as a function closure value which is unlikely).


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • New Features

    • Updated configuration files to support newer protobuf and JSON handling libraries.
    • Introduced new dependencies to enhance functionality.
  • Improvements

    • Refined module handling and error checking across various components for better stability.
    • Updated Go package paths for improved module organization.
    • Added support for new protobuf plugin configurations.
  • Documentation

    • Enhanced comments and descriptions in protobuf files for better clarity.

Copy link
Contributor

coderabbitai bot commented Jul 10, 2024

Walkthrough

Walkthrough

The changes primarily focus on enhancing the depinject/appconfig package by introducing protojson and dynamicpb for JSON unmarshaling and updating the generic proto message handling. This also includes reorganization of protobuf dependencies, adjustments in registry and module descriptor functions, and updates to Go package paths across various proto files. Indirect dependencies on github.com/tendermint/go-amino were added in multiple go.mod files.

Changes

File(s) Change Summary
depinject/appconfig/config.go Updated LoadJSON to use protojson and dynamicpb. Modified Compose to accept gogoproto.Message.
depinject/go.mod, orm/go.mod, runtime/v2/go.mod Added indirect dependency on github.com/tendermint/go-amino v0.16.0. Removed direct dependency on google.golang.org/grpc v1.64.1 in depinject/go.mod.
depinject/internal/appconfig/buf.gen.pulsar.yaml Introduced new configuration for go-pulsar plugin.
depinject/internal/appconfig/buf.yaml, depinject/internal/appconfiggogo/buf.yaml Added dependency on buf.build/cosmos/cosmos-sdk.
depinject/internal/appconfig/registry.go Introduced new imports and updated ModulesByModuleTypeName to use GetModuleDescriptor with additional conversion and error handling.
depinject/internal/appconfig/testpb/test.proto, depinject/internal/appconfiggogo/testpb/test.proto Added go_package option for Go package path.
depinject/internal/appconfig/testpb/test.pulsar.go Changed import path to reflect new module organization.
depinject/internal/appconfiggogo/buf.gen.gogo.yaml Introduced configuration for gocosmos plugin.
proto/cosmos/app/v1alpha1/config.proto, proto/cosmos/app/v1alpha1/module.proto, proto/cosmos/app/v1alpha1/query.proto Updated go_package option to new path.
x/staking/proto/cosmos/staking/v1beta1/staking.proto Minor comment spacing adjustments.

Sequence Diagram(s)

No sequence diagrams are needed as the changes are mostly related to internal structuring, dependency updates, and configuration adjustments without introducing significant new features or control flow modifications.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@aaronc aaronc changed the title feat(depinject/appconfig): remove api module dependency, bump to v1 refactor(depinject/appconfig): remove api module dependency, bump to v1 Jul 10, 2024
api/cosmos/app/v1/config.pulsar.go Fixed Show fixed Hide fixed
api/cosmos/app/v1/config.pulsar.go Fixed Show fixed Hide fixed
api/cosmos/app/v1/config.pulsar.go Fixed Show fixed Hide fixed
api/cosmos/app/v1/config.pulsar.go Fixed Show fixed Hide fixed
api/cosmos/app/v1/config.pulsar.go Fixed Show fixed Hide fixed
api/cosmos/app/v1/config.pulsar.go Fixed Show fixed Hide fixed
api/cosmos/app/v1/config.pulsar.go Fixed Show fixed Hide fixed
@aaronc aaronc changed the title refactor(depinject/appconfig): remove api module dependency, bump to v1 refactor(depinject/appconfig): remove api module dependency Jul 10, 2024
@aaronc aaronc marked this pull request as ready for review July 10, 2024 17:54
@aaronc aaronc requested a review from a team as a code owner July 10, 2024 17:54
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ab6400f and 447ed19.

Files ignored due to path filters (6)
  • depinject/appconfig/v1alpha1/config.pb.go is excluded by !**/*.pb.go
  • depinject/appconfig/v1alpha1/module.pb.go is excluded by !**/*.pb.go
  • depinject/appconfig/v1alpha1/query.pb.go is excluded by !**/*.pb.go
  • depinject/go.sum is excluded by !**/*.sum
  • depinject/internal/appconfiggogo/testpb/test.pb.go is excluded by !**/*.pb.go
  • x/staking/types/staking.pb.go is excluded by !**/*.pb.go
Files selected for processing (15)
  • api/cosmos/staking/v1beta1/staking.pulsar.go (4 hunks)
  • depinject/appconfig/config.go (5 hunks)
  • depinject/go.mod (2 hunks)
  • depinject/internal/appconfig/buf.gen.pulsar.yaml (1 hunks)
  • depinject/internal/appconfig/buf.yaml (1 hunks)
  • depinject/internal/appconfig/registry.go (3 hunks)
  • depinject/internal/appconfig/testpb/test.proto (1 hunks)
  • depinject/internal/appconfig/testpb/test.pulsar.go (2 hunks)
  • depinject/internal/appconfiggogo/buf.gen.gogo.yaml (1 hunks)
  • depinject/internal/appconfiggogo/buf.yaml (1 hunks)
  • depinject/internal/appconfiggogo/testpb/test.proto (1 hunks)
  • proto/cosmos/app/v1alpha1/config.proto (1 hunks)
  • proto/cosmos/app/v1alpha1/module.proto (1 hunks)
  • proto/cosmos/app/v1alpha1/query.proto (1 hunks)
  • x/staking/proto/cosmos/staking/v1beta1/staking.proto (2 hunks)
Files not summarized due to errors (1)
  • api/cosmos/staking/v1beta1/staking.pulsar.go: Error: Message exceeds token limit
Files skipped from review due to trivial changes (7)
  • depinject/internal/appconfig/buf.gen.pulsar.yaml
  • depinject/internal/appconfig/buf.yaml
  • depinject/internal/appconfig/testpb/test.proto
  • depinject/internal/appconfiggogo/buf.gen.gogo.yaml
  • depinject/internal/appconfiggogo/buf.yaml
  • depinject/internal/appconfiggogo/testpb/test.proto
  • x/staking/proto/cosmos/staking/v1beta1/staking.proto
Additional context used
Path-based instructions (4)
depinject/internal/appconfig/registry.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

depinject/appconfig/config.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

depinject/internal/appconfig/testpb/test.pulsar.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

api/cosmos/staking/v1beta1/staking.pulsar.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

GitHub Check: break-check
proto/cosmos/app/v1alpha1/query.proto

[failure] 7-7:
File option "go_package" changed from "cosmossdk.io/api/app/v1alpha1" to "cosmossdk.io/depinject/appconfig/v1alpha1".

proto/cosmos/app/v1alpha1/config.proto

[failure] 7-7:
File option "go_package" changed from "cosmossdk.io/api/app/v1alpha1" to "cosmossdk.io/depinject/appconfig/v1alpha1".

proto/cosmos/app/v1alpha1/module.proto

[failure] 7-7:
File option "go_package" changed from "cosmossdk.io/api/app/v1alpha1" to "cosmossdk.io/depinject/appconfig/v1alpha1".

Additional comments not posted (14)
proto/cosmos/app/v1alpha1/query.proto (1)

7-7: Update go_package to reflect new package path.

The go_package option has been correctly updated to match the new package organization. This is consistent with the changes described in the PR summary.

Tools
GitHub Check: break-check

[failure] 7-7:
File option "go_package" changed from "cosmossdk.io/api/app/v1alpha1" to "cosmossdk.io/depinject/appconfig/v1alpha1".

depinject/go.mod (1)

10-10: Update dependencies to reflect package reorganization.

The dependency on google.golang.org/grpc has been removed, and github.com/tendermint/go-amino has been added as an indirect dependency. These changes are consistent with the package reorganization described in the PR summary.

Also applies to: 22-22

proto/cosmos/app/v1alpha1/config.proto (1)

7-7: Update go_package to reflect new package path.

The go_package option has been correctly updated to match the new package organization. This is consistent with the changes described in the PR summary.

Tools
GitHub Check: break-check

[failure] 7-7:
File option "go_package" changed from "cosmossdk.io/api/app/v1alpha1" to "cosmossdk.io/depinject/appconfig/v1alpha1".

depinject/internal/appconfig/registry.go (3)

8-9: Add necessary imports for protobuf handling.

The new imports from google.golang.org/protobuf and github.com/cosmos/gogoproto/protoc-gen-gogo/descriptor are appropriate and necessary for handling protobuf descriptors.

Also applies to: 11-11


41-41: Enhance module descriptor handling in ModulesByModuleTypeName.

The changes to the ModulesByModuleTypeName function improve the handling and error reporting of module descriptors using the new GetModuleDescriptor function.

Also applies to: 44-46, 52-56


74-116: Add GetModuleDescriptor function for module descriptor handling.

The new GetModuleDescriptor function effectively handles module descriptors with comprehensive error handling and compatibility with both gogoproto and protoreflect types.

proto/cosmos/app/v1alpha1/module.proto (1)

7-7: Approve the change for go_package option.

The go_package option has been updated to reflect the new package path, ensuring consistency across the codebase.

Tools
GitHub Check: break-check

[failure] 7-7:
File option "go_package" changed from "cosmossdk.io/api/app/v1alpha1" to "cosmossdk.io/depinject/appconfig/v1alpha1".

depinject/appconfig/config.go (2)

24-34: Approve changes in LoadJSON.

The function has been updated to use protojson and dynamicpb, avoiding direct dependencies on API types. This improves flexibility and maintainability.

However, ensure that gogoproto.HybridResolver and dynamicpb.NewMessage are used correctly and that error handling is appropriate.

Verification successful

Verification successful.

The usage of gogoproto.HybridResolver and dynamicpb.NewMessage is consistent and valid across the codebase. The changes in depinject/appconfig/config.go are appropriate and maintain the expected functionality.

  • depinject/appconfig/config.go
    • Line 24: resolver := gogoproto.HybridResolver
    • Line 30: config := dynamicpb.NewMessage(desc.(protoreflect.MessageDescriptor))
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `gogoproto.HybridResolver` and `dynamicpb.NewMessage`.

# Test: Search for the usage of `gogoproto.HybridResolver`. Expect: Only valid usages.
rg --type go 'gogoproto.HybridResolver'

# Test: Search for the usage of `dynamicpb.NewMessage`. Expect: Only valid usages.
rg --type go 'dynamicpb.NewMessage'

Length of output: 3190


Line range hint 64-157: Approve changes in Compose.

The function has been updated to accept gogoproto.Message instead of appv1alpha1.Config, improving flexibility. The conversion logic appears to be correct, and error handling is appropriate.

However, ensure that the conversion logic handles all possible cases and that error handling is thorough.

depinject/internal/appconfig/testpb/test.pulsar.go (1)

5-5: Verify the correctness of the new import path.

The import path has been updated from cosmossdk.io/api/cosmos/app/v1alpha1 to cosmossdk.io/depinject/appconfig/v1alpha1. Ensure that this new path exists and is correct.

Verification successful

Verified: The new import path cosmossdk.io/depinject/appconfig/v1alpha1 is correct and exists in the codebase.

The import statement has been successfully updated to align with the refactoring objective and does not introduce any issues.

  • depinject/internal/appconfig/registry.go
  • depinject/internal/appconfig/testpb/test.pulsar.go
  • depinject/internal/appconfiggogo/testpb/test.pb.go
  • depinject/appconfig/config.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and correctness of the new import path.

# Test: Check if the new import path exists. Expect: The path should exist and be correct.
rg --type go 'cosmossdk.io/depinject/appconfig/v1alpha1'

Length of output: 413

api/cosmos/staking/v1beta1/staking.pulsar.go (4)

15011-15013: Deprecation of HistoricalEntries field is approved.

The HistoricalEntries field is now marked as deprecated. Consider removing this field in a future release to clean up the codebase.


15064-15067: Addition and deprecation of GetHistoricalEntries method is approved.

The function GetHistoricalEntries is added and marked as deprecated. Consider removing this method in a future release to clean up the codebase.


15704-15707: Verify consistency of protobuf changes.

Ensure that the protobuf changes in this segment are consistent with the rest of the protobuf definitions in the project.


15714-15850: Verify consistency of protobuf changes and encoded data.

Ensure that the protobuf changes and encoded data in this segment are consistent with the rest of the protobuf definitions in the project.

@github-actions github-actions bot added the C:orm label Jul 10, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 447ed19 and fc5c517.

Files ignored due to path filters (2)
  • orm/go.sum is excluded by !**/*.sum
  • runtime/v2/go.sum is excluded by !**/*.sum
Files selected for processing (2)
  • orm/go.mod (1 hunks)
  • runtime/v2/go.mod (1 hunks)
Files skipped from review due to trivial changes (2)
  • orm/go.mod
  • runtime/v2/go.mod

Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK

Co-authored-by: Marko <marko@baricevic.me>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fc5c517 and 70277ec.

Files selected for processing (1)
  • depinject/internal/appconfig/registry.go (3 hunks)
Additional context used
Path-based instructions (1)
depinject/internal/appconfig/registry.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

GitHub Check: tests (03)
depinject/internal/appconfig/registry.go

[failure] 41-41:
dp declared and not used

GitHub Check: tests (02)
depinject/internal/appconfig/registry.go

[failure] 41-41:
dp declared and not used

GitHub Check: tests (01)
depinject/internal/appconfig/registry.go

[failure] 41-41:
dp declared and not used

GitHub Check: tests (00)
depinject/internal/appconfig/registry.go

[failure] 41-41:
dp declared and not used

GitHub Check: dependency-review
depinject/internal/appconfig/registry.go

[failure] 41-41:
dp declared and not used

Additional comments not posted (2)
depinject/internal/appconfig/registry.go (2)

73-115: Robust error handling in GetModuleDescriptor.

The function has comprehensive error handling for its operations, which is crucial given the complexity of the operations involved. Continue to monitor and test these paths to ensure reliability.


41-52: Ensure robust error handling and logic in module descriptor retrieval.

The function correctly handles potential errors when fetching module descriptors. However, ensure that all possible error scenarios are covered, especially in dynamic type conversions and protobuf operations.

Verification successful

Error handling in ModulesByModuleTypeName function is adequate.

The function ModulesByModuleTypeName appropriately handles errors through multiple checks and returns, ensuring robust error handling and logic in module descriptor retrieval.

  • if err != nil checks are used to handle errors.
  • fmt.Errorf is used to provide descriptive error messages.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify error handling paths in `ModulesByModuleTypeName`.

# Test: Search for error handling in the function. Expect: Proper error handling for all operations.
rg --type go -A 5 $'error handling in ModulesByModuleTypeName' depinject/internal/appconfig/registry.go

Length of output: 104


Script:

#!/bin/bash
# Description: Verify error handling within the `ModulesByModuleTypeName` function.

# Step 1: Search for the `ModulesByModuleTypeName` function definition.
rg 'func ModulesByModuleTypeName' -A 20 depinject/internal/appconfig/registry.go

# Step 2: Search for error handling within the `ModulesByModuleTypeName` function.
rg 'ModulesByModuleTypeName' -A 50 depinject/internal/appconfig/registry.go | rg 'if err != nil|return nil, err|fmt.Errorf'

Length of output: 1167

Tools
GitHub Check: tests (03)

[failure] 41-41:
dp declared and not used

GitHub Check: tests (02)

[failure] 41-41:
dp declared and not used

GitHub Check: tests (01)

[failure] 41-41:
dp declared and not used

GitHub Check: tests (00)

[failure] 41-41:
dp declared and not used

GitHub Check: dependency-review

[failure] 41-41:
dp declared and not used

@@ -35,12 +38,18 @@
fullName := gogoproto.MessageName(initializer.ConfigProtoMessage)

if desc, err := gogoproto.HybridResolver.FindDescriptorByName(protoreflect.FullName(fullName)); err == nil {
modDesc := protov2.GetExtension(desc.Options(), appv1alpha1.E_Module).(*appv1alpha1.ModuleDescriptor)
dp := protodesc.ToDescriptorProto(desc.(protoreflect.MessageDescriptor))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused variable dp.

The variable dp is declared but not used, which could lead to confusion and clutter in the code.

- dp := protodesc.ToDescriptorProto(desc.(protoreflect.MessageDescriptor))
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
dp := protodesc.ToDescriptorProto(desc.(protoreflect.MessageDescriptor))
Tools
GitHub Check: tests (03)

[failure] 41-41:
dp declared and not used

GitHub Check: tests (02)

[failure] 41-41:
dp declared and not used

GitHub Check: tests (01)

[failure] 41-41:
dp declared and not used

GitHub Check: tests (00)

[failure] 41-41:
dp declared and not used

GitHub Check: dependency-review

[failure] 41-41:
dp declared and not used

Comment on lines +73 to +115
// GetModuleDescriptor returns the cosmos.app.v1alpha1.ModuleDescriptor or nil if one isn't found.
// Errors are returned in unexpected cases.
func GetModuleDescriptor(desc protoreflect.Descriptor) (*v1alpha1.ModuleDescriptor, error) {
// we need to take a somewhat round about way to get the extension here
// our most complete type registry has a mix of gogoproto and protoreflect types
// so we start with a protoreflect descriptor, convert it to a gogo descriptor
// and then get the extension by its raw field value to avoid any unmarshaling errors

rawV2Desc := protodesc.ToDescriptorProto(desc.(protoreflect.MessageDescriptor))
bz, err := protov2.Marshal(rawV2Desc)
if err != nil {
return nil, err
}
var gogoDesc descriptor.DescriptorProto
err = gogoproto.Unmarshal(bz, &gogoDesc)
if err != nil {
return nil, err
}

opts := gogoDesc.Options
if !gogoproto.HasExtension(opts, v1alpha1.E_Module) {
return nil, nil
}

bz, err = gogoproto.GetRawExtension(gogoproto.GetUnsafeExtensionsMap(opts), v1alpha1.E_Module.Field)
if err != nil {
return nil, err
}

// we have to skip the field tag and length prefix itself to actually get the raw bytes we want
// this is really overly complex, but other methods caused runtime errors because of validation
// that gogo does that appears simply not necessary
_, _, n := protowire.ConsumeTag(bz)
bz, _ = protowire.ConsumeBytes(bz[n:])

var ext v1alpha1.ModuleDescriptor
err = gogoproto.Unmarshal(bz, &ext)
if err != nil {
return nil, err
}

return &ext, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider simplifying the descriptor handling in GetModuleDescriptor.

The function involves complex byte manipulations and conversions between different protobuf types. Consider simplifying these operations to improve maintainability and reduce the risk of errors.

- // Current complex byte manipulation
- _, _, n := protowire.ConsumeTag(bz)
- bz, _ = protowire.ConsumeBytes(bz[n:])
+ // Simplified approach (example, needs specific adjustment)
+ bz = simplifyByteHandling(bz)

Committable suggestion was skipped due to low confidence.

@julienrbrt
Copy link
Member

This is the perfect branch for me to use for #20767. I'll test those changes on v0.50 and v0.47

@@ -35,12 +38,18 @@
fullName := gogoproto.MessageName(initializer.ConfigProtoMessage)

if desc, err := gogoproto.HybridResolver.FindDescriptorByName(protoreflect.FullName(fullName)); err == nil {
modDesc := protov2.GetExtension(desc.Options(), appv1alpha1.E_Module).(*appv1alpha1.ModuleDescriptor)
dp := protodesc.ToDescriptorProto(desc.(protoreflect.MessageDescriptor))

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of dp is never used.
@@ -35,12 +38,18 @@ func ModulesByModuleTypeName() (map[string]*ModuleInitializer, error) {
fullName := gogoproto.MessageName(initializer.ConfigProtoMessage)

if desc, err := gogoproto.HybridResolver.FindDescriptorByName(protoreflect.FullName(fullName)); err == nil {
modDesc := protov2.GetExtension(desc.Options(), appv1alpha1.E_Module).(*appv1alpha1.ModuleDescriptor)
dp := protodesc.ToDescriptorProto(desc.(protoreflect.MessageDescriptor))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compile err here, unused var

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I will clean it up. Was debugging and forgot to delete

Copy link
Member

@kocubinski kocubinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 70277ec and f8adf8d.

Files selected for processing (2)
  • depinject/internal/appconfig/registry.go (3 hunks)
  • runtime/v2/go.mod (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • depinject/internal/appconfig/registry.go
  • runtime/v2/go.mod

@kocubinski kocubinski added this pull request to the merge queue Jul 18, 2024
Merged via the queue into main with commit 2e0e6d8 Jul 18, 2024
77 of 78 checks passed
@kocubinski kocubinski deleted the aaronc/appconfig-remove-api-dep branch July 18, 2024 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants